package com.e5.training.service;

import java.util.List;

import com.e5.training.domain.User;

/**
 * provide the service of user relational
 * 
 * @author Felix included methods must throws Exception to make sure that in
 *         action we can catch them to deal with
 */
public interface UserService {
	/**
	 * user to login
	 * 
	 * @param userid
	 *            page login.jsp transfer the userid to login
	 * @param password
	 *            page login.jsp transfer the password to login validate
	 * @return a instance of User to put in Sessioin ,if not invalid return null
	 * @throws Exception
	 */
	public User login(String userid, String password) throws Exception;

	/**
	 * 
	 * @return
	 * @throws Exception
	 */
	public User getUserByUserId(String userid) throws Exception;

	/**
	 * list all user in the website include current user .. may be enhanced for
	 * Pagination
	 * 
	 * @return list of users
	 * @throws Exception
	 */
	public List<User> listAllUser() throws Exception;

	/**
	 * signup the website
	 * 
	 * @param user
	 *            formbean
	 * @return set return User to session,then direct to the main.jsp
	 * @throws Exception
	 */
	public boolean signup(User user) throws Exception;

	/**
	 * to modify user's information
	 * 
	 * @param user
	 *            must have primary key id,transfer from jsp,not use setXXX for
	 *            each parameters of User.
	 * @return if success
	 * @throws Exception
	 */
	public boolean editUser(User user) throws Exception;

	/**
	 * delete user according to the primary key id
	 * 
	 * @param id
	 * @return if success
	 * @throws Exception
	 */
	public boolean delUser(Integer id) throws Exception;

	public User getUser(String userId);

}
